package fun.ipconfig;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import fun.ipconfig.entity.TestEntity;
import fun.ipconfig.utils.ExcelWorkbookUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;



public class App {

    
    public static void main(String[] args) throws IOException {
        List<TestEntity> u = new ArrayList<>();
        for(int i = 0;i<10;i++){
            TestEntity x = new TestEntity();
            x.setName("测试");
            u.add(x);
        }
        
        ExcelWorkbookUtils.getInstanceXlsx()
                .createSheet("sheet1")
                .setHeader(new String[]{"name", "user"})
                .foreach(u, (f) -> new Object[]{f.getName()})
                .end()
                .createSheet("sheet2")
                .setHeader(new String[]{"头部信息1","头部信息2"}, (style, font) -> {
                    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                    style.setBorderTop(HSSFCellStyle.BORDER_THIN);
                    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                    style.setBorderRight(HSSFCellStyle.BORDER_THIN);
                })
                .foreach(u,(f)->new Object[]{f.getName()+"test", "==>>"+f.getName()},(style, font) -> {
                    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                    style.setBorderTop(HSSFCellStyle.BORDER_THIN);
                    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                    style.setBorderRight(HSSFCellStyle.BORDER_THIN);
                })
                .end()
                .writerTo(new FileOutputStream("D:\\x1.xls"));
    }
}
